
# 客户端，访问服务器端，下载某个文件
import urllib.parse
import urllib.request
# url是下载文件的接口
url="http://127.0.0.1:5000/download"
try:
    # html=urllib.request.urlopen(url)
    # html = html.read()
    # fileName=html.decode()
    # 要下载的文件名
    fileName= "dog.jpg"
    print("准备下载:"+fileName)
    data=urllib.request.urlopen(url+"?fileName="+urllib.parse.quote(fileName))
    data = data.read()
    fobj=open("download "+fileName,"wb")
    fobj.write(data)
    fobj.close()
    print("下载完毕:",len(data),"字节")
except Exception as err:
    print(err)
